<html>
<head><meta charset="utf-8"><title>How can I lint on an item not in the current crate? · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20can.20I.20lint.20on.20an.20item.20not.20in.20the.20current.20crate.3F.html">How can I lint on an item not in the current crate?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="211292787"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20can%20I%20lint%20on%20an%20item%20not%20in%20the%20current%20crate%3F/near/211292787" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20can.20I.20lint.20on.20an.20item.20not.20in.20the.20current.20crate.3F.html#211292787">(Sep 25 2020 at 18:04)</a>:</h4>
<p>Currently rustdoc uses <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html#method.struct_span_lint_hir"><code>struct_span_lint_hir</code></a>, which requires a HirId. Is there a way to report errors for items in a different crate? I found <code>tcx.sess.diagnostic()</code>, but it looks like that requires knowing whether it's an error or warning ahead of time: what I want to do is emit a lint instead.</p>



<a name="211305735"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20can%20I%20lint%20on%20an%20item%20not%20in%20the%20current%20crate%3F/near/211305735" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20can.20I.20lint.20on.20an.20item.20not.20in.20the.20current.20crate.3F.html#211305735">(Sep 25 2020 at 19:29)</a>:</h4>
<p>there's no mapping to lint levels other than the HirId, so any <code>#[allow(...)]</code> would not be honored</p>



<a name="211307238"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/How%20can%20I%20lint%20on%20an%20item%20not%20in%20the%20current%20crate%3F/near/211307238" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/How.20can.20I.20lint.20on.20an.20item.20not.20in.20the.20current.20crate.3F.html#211307238">(Sep 25 2020 at 19:35)</a>:</h4>
<p><span class="user-mention" data-user-id="210316">@GuillaumeGomez</span> and I traced this to a rustdoc bug of some sort, it looks like <code>pub use x;</code> items are not a <code>UseItem</code> like they should be but instead an <code>ImplItem</code>. If I had the <code>UseItem</code> the id would be in the current crate and I wouldn't need to mess with <code>DefId</code>s.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>